import { queryChannelList, optChannelOrderAudit, getChannelDetail } from '../../src/api/apis'

const Mock = require('mockjs')
const { Random } = Mock

const data = Mock.mock({
  'list|1-60': [{
    'id|+1': 1,
    'goodsOptCode|+1': 1,
    'status|1': [10, 20, 30, 40],
    createTime: Mock.mock('@date("yyyy-MM-dd")'),
    creator: Mock.mock('@name'),
    fromChannel: '',
    operator: Mock.mock('@name'),
    submitTime: Mock.mock('@date("yyyy-MM-dd")'),
    toChannel: Random.image('200x100', '#FF6600'),
    totalAmount: 109018,
    totalNumber: 182
  }]
})

const goodsOptDetails = Mock.mock({
  'list|1-20': [{
    brand: 'AAA',
    color: '钛银灰',
    costPrice: '999.00',
    discount: null,
    goodsName: '【市场价2532】HUAWEI WATCH 2 Pro 4G智能手表 移动支付',
    id: 268,
    itemCode: '1115858781313032267',
    num: '10',
    purchasePrice: '999.00',
    sellPrice: '1336.00',
    skcCode: '1115858781313032265',
    spuCode: '108292253584138649790663',
    tagPrice: '2532.00',
    totalCostPrice: '9990.0',
    totalUnitPrice: '25320.0',
    unitPrice: '2532.00',
    urls: ['http://devdev.oss-cn-shanghai.aliyuncs.com/e95feeb570f9442dc51b233e8a7c6a7c5f2ab048_1554374016293_63.jpg']
  }]
})

const obj = {
  createTime: '2019-04-30 03:50:46',
  creator: '',
  fromChannel: 'akc',
  goodsOptCode: '11277895761229587456',
  operator: '',
  status: '10',
  submitTime: '2019-04-30 03:50:46',
  toChannel: 'ddc',
  totalAmount: 27920,
  totalNumber: 20
}

const channelList = data.list

export default [
  {
    url: queryChannelList,
    type: 'get',
    response: req => {
      let { pageNum, pageSize } = req.query
      pageNum = pageNum || 1
      pageSize = pageSize || 10

      const newData = channelList
      return {
        code: 20000,
        data: {
          list: newData.slice((pageNum - 1) * pageSize, pageNum * pageSize),
          total: newData.length
        }
      }
    }
  },
  {
    url: optChannelOrderAudit,
    type: 'post',
    response: req => {
      console.log('request===', req.body)
      return {
        code: 20000,
        data: {}
      }
    }
  },
  {
    url: getChannelDetail,
    type: 'get',
    response: req => {
      const { goodsOptCode } = req.query
      return {
        code: 20000,
        data: {}
      }
    }
  }
]
